<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>添加行政区域</title>
<link href="${ctx }/css/style.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="${ctx }/js/niceValidator/jquery.validator.css" />
<script type="text/javascript" src="${ctx }/js/jquery/jquery-1.8.2.min.js"></script>
<link rel="stylesheet" href="${ctx }/js/layui/css/layui.css " media="all"/>
<script type="text/javascript" src="${ctx }/js/layer/layer.js"></script>
<script type="text/javascript" src="${ctx }/js/niceValidator/jquery.validator.js"></script>
<script type="text/javascript" src="${ctx }/js/niceValidator/local/zh_CN.js"></script>
<script type="text/javascript" src="${ctx }/js/common.js"></script>
<style type="text/css">
        .layui-btn{
            margin-left: 101px;
            margin-top: 10px;
        }
</style>
</head>
<body>

<div class="formbody">
<form id="submitForm">
    <input type="hidden" name="parentid" value="${parentid}" />
    <input type="hidden" name="level" value="${level}" />
    <input type="hidden" name="position" value="${position}" />
  <ul class="forminfo">
	 <li>
      <label>ID</label>
      <input name="id" type="text" class="dfinput"  data-rule="ID:required;digitsnew;"/>
   	 </li>
	 <li>
      <label>行政区域名</label>
      <input name="areaname" type="text"  class="dfinput"  data-rule="行政区域名:required;"/>
   	 </li>
	 <li>
      <label>简称</label>
      <input name="shortname" type="text" class="dfinput"  data-rule="简称:required;"/>
   	 </li>
	 <li>
      <label>区域码</label>
      <input name="areacode" type="text" class="dfinput"  data-rule=""/>
   	 </li>
	 <li>
      <label>邮政编码</label>
      <input name="zipcode" type="text" class="dfinput"  data-rule=""/>
   	 </li>
	 <li>
      <label>拼音名</label>
      <input name="pinyin" type="text" class="dfinput"  data-rule=""/>
   	 </li>
	 <li>
      <label>排序</label>
      <input name="sort" type="text" class="dfinput"  data-rule="排序:required;"/>
   	 </li>
    <li>
      <label>&nbsp;</label>
      <input name="" id="submitBtn" type="button" class="btn" value="确认保存"/>
    </li>
  </ul>
</form>
</div>
</body>
</html>
<script type="text/javascript" src="${ctx }/js/layui/layui.js"></script>
<script>
    function add(url) {
        var index = parent.layer.getFrameIndex(window.name);
        $("#submitForm").trigger("validate");
        instance = $("#submitForm").data("validator");
        if (instance.isFormValid()) {
            var loadi = layer.load();
            var datajson = $("#submitForm").serialize();
            $.ajax({
                type : "POST",
                url : url,
                data : datajson,
                dataType : "json",
                success : function(data) {
                    layer.close(loadi);
                    if (data.status == 'SUCCESS') {
                        window.parent.baseBottomMsgOpen('添加成功');
                        //window.parent.ajaxLoadOrgansList(window.parent.selAreaId);
                        window.parent.refreshNode();
                        window.parent.layer.close(index);
                    } else {
                        layer.alert(data.msg);
                    }
                }
            });
        }
    }

    $(document).ready(function(){
        $("#submitBtn").click(function(){
            add('${ctx }/sysman/systemArea/addSystemArea.do');
        });
    });
</script>